#调用外部程序
#  os.system
#  subprocess.Popen  、 subprocess.PIPE


import os

# cmd = r'C:\Users\CC\Downloads\wget http://mirrors.sohu.com/nginx/nginx-1.13.9.zip'
# os.system(cmd)
# print('下载完毕')


#用于手动执行升级脚本
#
# subprocess模块中有很多调用外部程序的 
# 这里的shell的True或者False就是命令行是否打印出来

from subprocess import Popen,PIPE
# proc = Popen(
#     r'C:\Users\CC\Downloads\wget http://mirrors.sohu.com/nginx/nginx-1.13.9.zip',
#     stdin = None,
#     stdout = PIPE,
#     stderr = PIPE,
#     shell = False
# )

# outinfo,errinfo = proc.communicate()

# print('成功调用了communicate')
# outinfo = outinfo.decode('utf8')
# errinfo = errinfo.decode('utf8')

# print('------------我要开始打印outinfo----------------')
# print(outinfo)
# print('------------我要开始打印errinfo----------------')
# print(errinfo)


# windows_path = r'C:\Users\CC\Desktop\蔡沛言简历2024.docx'
# os.startfile(windows_path)


# #练习
import time
# process_path = r'D:\Notepad++\notepad++.exe'
# file_loc = r'E:\python-study2025\jinjie\jj03.py'
# cmd = f"{process_path} {file_loc} "
# print(cmd)
# process = Popen(
#     cmd,
#     stdin = None,
#     stdout = PIPE,
#     stderr = PIPE,
#     shell= True
#     )
# out1 , err1 = process.communicate()
# err1 = err1.decode('GBK')
# out1 = out1.decode('GBK')
# print(out1)
# time.sleep(2)



# cmd = r'tasklist'
# process2 = Popen(
#     cmd,
#     stdin=None,
#     stderr=PIPE,
#     stdout=PIPE,
#     shell=True
# )
# out2 , err2 = process2.communicate()
# print('执行到这里了')
# err2 = err2.decode('GBK')
# out2 = out2.decode('GBK')
# # print(err2)
# # print(out2)
# #结果在out2里面
# for i in out2.splitlines():
#     if not i:
#         continue
#     if i.count('notepad') != 0:
#         #获取pid
#         info_list = i.split(' ')
#         #info_list = [info for info in info_list if info]
#         youxiao_infolist = []
#         for j in info_list:
#             if not j :
#                 continue
#             youxiao_infolist.append(j)
#         pid = youxiao_infolist[1]
#         cmd = rf'taskkill /PID {pid} /F'
#         os.system(cmd)


pro_path = r'C:\Users\CC\Downloads\ffmpeg.exe'
target_path = r'D:\BaiduNetdiskDownload\callOthers'

import glob
def gaibianshengyin(prcess_path,target_path):
    file_name = os.path.join(target_path,'*.mp4')
    list1 = glob.glob(file_name) 
    # print(list1)
    os.chdir(target_path)
    for file_in in list1:
        file_name = os.path.basename(file_in)
        index1= file_name.find('.mp4')
        file_out = file_name[:index1]+'.new.mp4'
        cmd = rf'{prcess_path} -i "{file_in}" -af asetrate=44100*8.9/10,atempo=10/8.9 -c:v copy "{file_out}"'
        # print(cmd)
        Popen(cmd,shell=True)
# gaibianshengyin(pro_path,target_path)